e000dapr

;	lda #0
;	sta xd
;	lda #1
;	sta yd
	
	ldy #0
	sty znikajy

petelka	
	ldy znikajy
	lda znikaj,y
	cmp #$ff
	bne dddalej
	jmp end__
	
dddalej
	tax
	and #$0f
	sta yd
	
	txa
	
	lsr
	lsr
	lsr
	lsr
	sta xd
	
	jsr kwadrat
	ldx #3
	jsr timer

	inc znikajy

	jmp petelka
	
	;inc $d020
	
	jmp end__

kwadrat
	; 5x5 blocks
	; coord: y*5*40 + x*5

;var z;
;5*40 = 200
; 4x lsr , 4x adc , 10x lsr

; xd: 0~7 , yd: 0~4

	;lsr $c000,x
	;lda $d800,x


	lda #5
	sta kwad_y

	CLC

	LDA #0
	sta lom
	sta him

	lda xd	; multiplying X coord by 5 to create x offset
	asl
	asl
	clc
	adc xd
	sta xoffset
	

	LDA yd ; multiplying Y coord by 200
;	sta liczba
	ASL
	ASL
	ASL
	ASL

	ADC yd
	ADC yd
	ADC yd
	ADC yd

	ADC yd
	ADC yd
	ADC yd
	ADC yd

	ADC yd

	; accu: 40 max

	ldx #3
__l200x	ASL
	rol him
	dex
	bne __l200x	

	sta lom		; (accu * 200) @ lom, him
	sta $02		

;	lda him
;	clc
;	adc #$c0	; c000 + sth
;	sta $03


_3kupa	lda #4		; temporary : Y line  - pixel offest value 
	sta kwad_x
	clc
	adc xoffset
	tay
__kupa
	lda him
	clc
	adc #$c0
	sta $03
	lda #$00
	sta ($02),y

	lda him
	clc
	adc #$d8
	sta $03

	lda #$00
	sta ($02),y

	DEY
	dec kwad_x
	BPL __kupa

	

	clc
	lda $02
	adc #40
	sta $02
	bcc __kupa2
	inc him

__kupa2
	dec kwad_y
	bne _3kupa

	rts
;vars
kwad_y .byte 0 	; coord + kwad_y <*40> lines down
	
xd  .byte 0 ; x pixel 
	
yd  .byte 0	; y pixel
	

lom  .byte 0	; result lo , hi
	
him  .byte 0
	
xoffset .byte 0	; x pixel offset (y*40 + XOFFSET)
	
kwad_x .byte 0

	

znikajy .byte 0
	
znikaj
; tablica "znikan" , hi = x , lo = y
.byte $00,$20,$40,$60
.byte $11,$31,$51,$71
.byte $02,$22,$42,$62
.byte $13,$33,$53,$73
.byte $04,$24,$44,$64

.byte $00,00,00,00,00

.byte $74,$54,$34,$14
.byte $63,$43,$23,$03
.byte $72,$52,$32,$12
.byte $61,$41,$21,$01
.byte $70,$50,$30,$10

;.byte $14,$34,$54,$74
;.byte $03,$23,$43,$63
;.byte $12,$32,$52,$72
;.byte $01,$21,$41,$61
;.byte $10,$30,$50,$70

.byte $ff
	
end__
